package weaver.jobs.holyview.duss;

import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;


/**
 * @Title: ecology
 * @Company: weaver
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-10-30
 * @Description:
 * @ModifyLog:
 **/

public class WeaUpdateKhztCronJob extends BaseCronJob {
    @Override
    public void execute() {
        RecordSet rs = new RecordSet();
        RecordSet rs1 = new RecordSet();
        String curdate = DateUtil.getCurrentDate();
        String sql = "select id from uf_khjbxx where CONVERT(VARCHAR(10),dateadd(day, 15, modedatacreatedate),120)=?";
        rs.executeQuery( sql, curdate );
        while (rs.next()) {
            String id = Util.null2String( rs.getString( "id" ) );
            rs1.executeQuery("select max(zt) from uf_xmjbxx where khmc = ?",id);
            if(rs1.next()){
                String zt = Util.null2String( rs1.getString(1) );
                rs1.executeUpdate("update uf_khjbxx set khzt=? where id=?",zt,id);
            }else {
                rs1.executeUpdate("update uf_khjbxx set khzt=1 where id=?",id);
            }
        }

    }
}
